package ru.kipriz.todoly.api.util;

import java.util.Date;

/**
 * <p>Copyright: Copyright (c) 2010</p>
 *
 * @author Andrey Volkov
 *         <br/>Date: 3/25/11
 */
public class TokenObject {
    String tokenString;
    String userEmail;
    String expirationTime;
    long expirationMilliseconds;

    public String getTokenString() {
        return tokenString;
    }

    public void setTokenString(String tokenString) {
        this.tokenString = tokenString;
    }

    public String getUserEmail() {
        return userEmail;
    }

    public void setUserEmail(String userEmail) {
        this.userEmail = userEmail;
    }

    public String getExpirationTime() {
        return expirationTime;
    }

    public void setExpirationTime(String expirationTime) {
        this.expirationTime = expirationTime;
    }

    public boolean isExpired() {
        if (expirationMilliseconds == 0) {
            if (expirationTime.contains("Date(")) {
                String timeString = expirationTime.replace("\\/Date(", "").replace(")\\/", "");
                expirationMilliseconds = Long.parseLong(timeString);
            }
        }
        return System.currentTimeMillis() > expirationMilliseconds;
    }
}
